import { actionTypeCreatorWithNameSpace, createAction } from './util';
import agent from 'agent';

const actionTypeCreator = actionTypeCreatorWithNameSpace('builder');

export const newBuild = createAction(actionTypeCreator('newBuild'), (unitId) => {
  return agent.post(`/api/builders/build/${unitId}`)
    .then(response => response.body);
}, {
  fetch: {
    processing: true
  }
});

export const cancelBuild = createAction(actionTypeCreator('cancelBuild'), (uuid) => {
  return agent.post(`/api/builders/${uuid}/cancel`);
});
